
package Modele; 

import java.awt.Image;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;



public class Contact {
	
	private String nom, prenom;
	private String homeAdress, workAdress;
	private String mobilePersonalNumber, homePersonalNumber;
	private String mobileWorkNumber, officeWorkNumber;
	private String homepage, adressePhoto;
	private Image photo;
	private String virtualGroup; 
	private Date ajoutDate; 
	
	public Contact(){
		
		this.ajoutDate = new Date();
	}
	
	public Contact(String data){
		
		int cptAvant=0;
		int cpt=0;
		
		for(int i=0;i<data.length();i++){
			if(data.charAt(i)==';'){
				if(cpt==0)this.virtualGroup=data.substring(cptAvant, i);
				if(cpt==1) this.prenom=data.substring(cptAvant, i);
				if(cpt==2) this.nom=data.substring(cptAvant, i);
				
				if(cpt==3) this.homeAdress=data.substring(cptAvant, i);
				if(cpt==4) this.workAdress=data.substring(cptAvant, i);
				if(cpt==5) this.mobilePersonalNumber=data.substring(cptAvant, i);
				if(cpt==6) this.homePersonalNumber=data.substring(cptAvant, i);
				if(cpt==7) this.mobileWorkNumber=data.substring(cptAvant, i);
				if(cpt==8) this.officeWorkNumber=data.substring(cptAvant, i);
				if(cpt==9) this.homepage=data.substring(cptAvant, i);
				if(cpt==10)this.adressePhoto=data.substring(cptAvant, i);
				

				if(cpt==11) {
					SimpleDateFormat format = new SimpleDateFormat("dd/mm/yyyy");
					try {
						this.ajoutDate = format.parse ( data.substring(cptAvant, i) );
					} catch (ParseException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} 

				}
				cptAvant=i+1;
				cpt++;				
				
			}
			
		}
		
	}
	
	public Contact(String nom, String prenom, String homeAdress, String workAdress,String mobilePersonalNumber, String homePersonalNumber,
			String mobileWorkNumber, String officeWorkNumber, String homepage, String virtualGroup){
		
		this.nom = nom;
	    this.prenom = prenom;
	    this.homeAdress = homeAdress;
	    this.workAdress = workAdress;
	    this.mobilePersonalNumber=mobilePersonalNumber;
	    this.homePersonalNumber =homePersonalNumber;
	    this.mobileWorkNumber =mobileWorkNumber;
	    this.officeWorkNumber =officeWorkNumber;
	    this.homepage=homepage;
	    this.virtualGroup = virtualGroup; 
	    
	   
		this.ajoutDate = new Date();
		
	}
	
	public Contact(String nom, String prenom, String homeAdress, String workAdress,String mobilePersonalNumber, String homePersonalNumber,
			String mobileWorkNumber, String officeWorkNumber, String homepage){
		
		this.nom = nom;
	    this.prenom = prenom;
	    this.homeAdress = homeAdress;
	    this.workAdress = workAdress;
	    this.mobilePersonalNumber=mobilePersonalNumber;
	    this.homePersonalNumber =homePersonalNumber;
	    this.mobileWorkNumber =mobileWorkNumber;
	    this.officeWorkNumber =officeWorkNumber;
	    this.homepage=homepage;
		
	}
	
	
	
	public String getNom() {
		return nom;
	}
	public void setNom(String nom) {
		this.nom = nom;
	}
	public String getPrenom() {
		return prenom;
	}
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
	public String getHomeAdress() {
		return homeAdress;
	}
	public void setHomeAdress(String homeAdress) {
		this.homeAdress = homeAdress;
	}
	public String getWorkAdress() {
		return workAdress;
	}
	public void setWorkAdress(String workAdress) {
		this.workAdress = workAdress;
	}
	public String getMobilePersonalNumber() {
		return mobilePersonalNumber;
	}
	public void setMobilePersonalNumber(String mobilePersonalNumber) {
		this.mobilePersonalNumber = mobilePersonalNumber;
	}
	public String getHomePersonalNumber() {
		return homePersonalNumber;
	}
	public void setHomePersonalNumber(String homePersonalNumber) {
		this.homePersonalNumber = homePersonalNumber;
 	}
	public String getMobileWorkNumber() {
		return mobileWorkNumber;
	}
	public void setMobileWorkNumber(String mobileWorkNumber) {
		this.mobileWorkNumber = mobileWorkNumber;
	}
	public String getOfficeWorkNumber() {
		return officeWorkNumber;
	}
	public void setOfficeWorkNumber(String officeWorkNumber) {
		this.officeWorkNumber = officeWorkNumber;
	}
	public String getHomepage() {
		return homepage;
	}
	public void setHomepage(String homepage) {
		this.homepage = homepage;
	}
	public Image getPhoto() {
		return photo;
	}
	public void setPhoto(Image photo) {
		this.photo = photo;
	}
	public String getVirtualGroup() {
		return virtualGroup;
	}
	public void setVirtualGroup(String virtualGroup) {
		this.virtualGroup = virtualGroup;
	}


	public Date getAjoutDate() {
		return ajoutDate;
	}


	public void setAjoutDate(Date ajoutDate) {
		this.ajoutDate = ajoutDate;
	}

	@Override
	public String toString() {
		return "" + nom + ";" + prenom + " ;"
				+ homeAdress + ";" + workAdress
				+ ";" + mobilePersonalNumber
				+ ";" + homePersonalNumber
				+ ";" + mobileWorkNumber
				+ ";" + officeWorkNumber + " ;"
				+ homepage + ";" + photo + "";
	} 
	
	public String toStringBasic() {
		return ""+ prenom + " " + nom +"";
	}
	

}